function showTeacher(id) {
	document.team1.teacherID.value = id;
	openDiv("teacher_contant");
	openDiv("mask");
	dojo.event.topic.publish("show_detail");
}
function show_user_details(id) {
	document.team1.teacherID.value = id.value;
	openDiv("teacher_contant");
	openDiv("mask");
	closeVDiv('teamClass');
	closeVDiv('left');
	closeVDiv('right');
	dojo.event.topic.publish("show_detail");
}
/************************打开提交任务书div********************************/
function openTaskUpload(id) {
	
	document.getElementById("uploadFrame").src = "../blank.jsp";
	var addFile = document.getElementById("addFile");
	document.taskUploadForm.topicsID.value = id;
	document.taskUploadForm.setAttribute("action", "task/uploadTask.action");
	addFile.onclick = addTaskFile;
	document.getElementById("c_head").innerHTML = "提交任务书";
	openDiv("taskUpload_contant");
	openDiv("fileContainer");
	openDiv("mask");
	openDiv("taskDiv");
	closeDiv("resourceDIv");
	closeDiv("uploadFrame");
	clearTaskTable();
	
	var new_div = document.createElement("div");
	new_div.setAttribute("class", "fileContainer_2_1");
	new_div.style.margin = "0,0,0,60px";
	var new_label = document.createElement("label");
	var fileText;
	fileText = document.createTextNode("任务书:");
	new_label.appendChild(fileText);
	var new_input = document.createElement("input");
	new_input.setAttribute("type", "file");
	new_input.setAttribute("name", "upload");
	new_div.appendChild(new_label);
	new_div.appendChild(new_input);
	var taskUpload = document.getElementById("taskDiv");
	taskUpload.appendChild(new_div);
}
function addTaskFile() {
	addFile("task", "taskBook");
}

/************************设置时间点*********************/
function openSetTime()
{
	openDiv("setTime_contant");
	openDiv("mask")
}
/*******************************************************/
function submitForm(name,action)
{
	var f=document.getElementById(name);
	f.action=action;
	f.submit();

}

//添加资源
function addFile(filename) {
	var new_div = document.createElement("div");
	new_div.setAttribute("class", "fileContainer_2_1");
	new_div.style.margin = "0,0,0,60px";
	var new_label = document.createElement("label");
	var fileText;
	fileText = document.createTextNode("资源:");
	new_label.appendChild(fileText);
	var new_input = document.createElement("input");
	new_input.setAttribute("type", "file");
	new_input.setAttribute("name", filename);
	new_div.appendChild(new_label);
	new_div.appendChild(new_input);
	var taskUpload = document.getElementById("taskUploadDiv");
	taskUpload.appendChild(new_div);
}
function deleteFile() {
	var taskUpload = document.getElementById("taskUploadDiv");
	var alldiv = taskUpload.getElementsByTagName("div");
	if (alldiv.length != 0) {
		taskUpload.removeChild(alldiv[alldiv.length - 1]);
	}
}
function uploadTaskBook() {
	closeDiv("fileContainer");
	openDiv("uploadFrame");
}
function checkTask() {
	var taskUpload = document.getElementById("taskUploadDiv");
	var allupload = taskUpload.getElementsByTagName("input");
	var action  = document.taskUploadForm.getAttribute("action");
	if(action == 'task/resource.action')
	{
		if(allupload.length==0)
		{
			alert("资料必须添加一个才能上传");
			return false;
		}
	}
	for (var i = 0; i < allupload.length; i++) {
		if (allupload[i].value == "") {
			alert("上传文件不能为空");
			return false;
		}else if(!judgeType(allupload[i].value))
		{
			return false;
		}
	}
	taskUpload = document.getElementById("taskDiv");
	allupload = taskUpload.getElementsByTagName("input");
	for (var i = 0; i < allupload.length; i++) {
		if (allupload[i].value == "") {
			alert("上传文件不能为空");
			return false;
		}else if(!judgeType(allupload[i].value))
		{
			return false;
		}
	}
	uploadTaskBook();
	return true;
}
function clearTaskTable() {
	var taskUpload = document.getElementById("taskUploadDiv");
	var taskDiv = taskUpload.getElementsByTagName("div");
	e = taskDiv.length - 1;
	for (e; e >= 0; e--) {
		taskUpload.removeChild(taskDiv[e]);
	}
	taskUpload = document.getElementById("taskDiv");
	taskDiv = taskUpload.getElementsByTagName("div");
	e = taskDiv.length - 1;
	for (e; e >= 0; e--) {
		taskUpload.removeChild(taskDiv[e]);
	}
}
/**********************************************打开上传资源 div*******************************/
function openResourceUpload(id) {
	document.getElementById("uploadFrame").src = "../blank.jsp";
	var addFile = document.getElementById("addFile");
	document.taskUploadForm.topicsTaskID.value = id;
	document.taskUploadForm.setAttribute("action", "task/resource.action");
	addFile.onclick = addResourceFile;
	document.getElementById("c_head").innerHTML = "上传资源框";
	openDiv("taskUpload_contant");
	openDiv("fileContainer");
	openDiv("mask");
	openDiv("resourceDIv");
	closeDiv("taskDiv");
	closeDiv("uploadFrame");
	clearTaskTable();
}
function addResourceFile() {
	addFile("resource", "resource");
}

//老师修改课题
/*
function openModifyTopics(topicsNum) {
	document.modifyTopics.topicsID.value=topicsNum;
		openDiv("modifys");
		openDiv("mask");
		dojo.event.topic.publish("modifyTopic");
}
*/
/************************开题报告答辩结果 js*******************************/
function openReportResult(id)
{
	document.reportResultForm.reset();
	document.getElementById("uploadFrame").src="../blank.jsp";
	document.reportResultForm.topicsID.value=id;
	openDiv("reportResult_contant");
	openDiv("fileContainer");
	openDiv("mask");
	closeDiv("uploadFrame");
}
/*****************************查看开题报告答辩结果***************************/
function openShowResult()
{
	openDiv("showResult_contant");
	openDiv("mask");
}
/********************************提交指导记录*************************************/
function openRecords(id)
{
	document.recordsForm.reset();
	document.getElementById("uploadFrame").src="../blank.jsp";
	document.recordsForm.topicsID.value=id;
	openDiv("records_contant");
	openDiv("fileContainer");
	openDiv("mask");
	closeDiv("uploadFrame");
}
function checkFile(id){
	var result = document.getElementById(id);
	if(result.value=="")
	{
		alert("上传文件不能为空");
		return false;
	}
	uploadTaskBook();
	return true;
}
/******************************一审************************************/
function openOneAuditing(id,which)
{
	var head = document.getElementById("c_head");
	//var whi = document.oneAuditingForm;
	if(which=='one')
	{
		head.innerHTML='提交一审表';
		document.oneAuditingForm.action='twiceAuditing/submitOneAuditing.action';
		//whi.which.value='one';
	}else{
		head.innerHTML='提交二审表';
		document.oneAuditingForm.action='twiceAuditing/submitTwoAuditing.action';
		//whi.which.value='two';
	}
	document.oneAuditingForm.reset();
	document.getElementById("uploadFrame").src="../blank.jsp";
	document.oneAuditingForm.topicsID.value=id;
	openDiv("oneAuditing_contant");
	openDiv("fileContainer");
	openDiv("mask");
	closeDiv("uploadFrame");
}
/*******************************答辩记录***********************************/
function openReplyRecorder(id)
{
	document.replyRecorderForm.reset();
	document.getElementById("uploadFrame").src="../blank.jsp";
	document.replyRecorderForm.topicsID.value=id;
	openDiv("replyRecorder_contant");
	openDiv("fileContainer");
	openDiv("mask");
	closeDiv("uploadFrame");
}
/*****************************录入考核成绩*********************************/
function openExaminging(id){
	document.examiningForm.reset();
	document.getElementById("uploadFrame").src="../blank.jsp";
	document.examiningForm.topicsID.value=id;
	openDiv("examining_contant");
	openDiv("fileContainer");
	openDiv("mask");
	closeDiv("uploadFrame");
}
function modifyScore(id,event)
{
	document.getElementById("scoreResult").innerHTML="";
	document.scoreForm.topicsID.value=id;
	document.scoreForm.scoreID.value=event.value;
	openDiv("score_contant");
	openDiv("scoreContent");
	openDiv("mask");
	hiddenSelect();
}
function closeScore()
{
	closeDiv("scoreContent");
}
/****************************再次答辩申请************************************/
function openAuditingReply(id,event)
{
	document.getElementById("scoreResult").innerHTML="";
	document.auditingReplyForm.topicsID.value=id;
	document.auditingReplyForm.stateID.value=event.value;
	openDiv("auditingReply_contant");
	openDiv("scoreContent");
	openDiv("mask");
	hiddenSelect();
}
function closeReply()
{
	deleteRow('topicsNum','result','topicsList');
	closediv('auditingReply_contant');
}
function openReplyResult()
{
	openDiv("showResult_contant");
	openDiv("mask");
}

function openModifyTopics(){
	//document.modifyTopics.topicsID.value=topicsNum;
		openDiv("modifys");
		openDiv("mask");
		//dojo.event.topic.publish("modifyTopic");
}
/**********************导入用户示例*************************/
function openShili(url){
	var div = document.getElementById("shili");
	var img = div.getElementsByTagName("img")[0];
	img.src = url;
	openDiv("shili");
	openDiv("mask");
	closeDiv('userType');
}
function closeShili()
{
	closediv('shili');
	openDiv('userType');
}
function openImportResult()
{
	document.getElementById("uploadFrame").src="admin/adminResult.jsp";
	openDiv("import_contant");
	openDiv("mask");
}
function checkUserFile(id)
{
	var result = document.getElementById(id);
	if(result.value=="")
	{
		alert("上传文件不能为空");
		return false;
	}
	openImportResult();
	return true;
}
function closeImportResult(id)
{
	document.importUser.reset();
	document.getElementById("uploadFrame").src="../admin/adminResult.jsp";
	closediv(id);
}
//隐藏所有的select标签
function hiddenSelect()
{
	var selectArray = document.getElementsByTagName("select");
	for(var i=0;i<selectArray.length;i++)
	{
		var yc=selectArray[i];
		if(yc.style.visibility=="visible")
		{
			yc.style.visibility="hidden";
		}
	}
}